# -*- coding: utf-8 -*-
"""
Created on Sat Dec 21 19:34:46 2024

@author: lenovo
"""

'''init'''
name = 'kangni'
file_path = r"D:\met_data\ty_obs\BABJWTPQ_2024\10\BABJ_2421.dat"
'''init'''

tysavepath = rf"D:\met_data\ty_obs\{name}_CMAobs.txt"  # 替换为你的文件路径
### readin
with open(file_path, "r", encoding='GBK') as file:
    lines = file.readlines()  # 按行读取文件内容

### 得到所有的初始行，利用数据第四列是000得到
s=[]
for i in range(3,len(lines)):     # 手动跳过前三行
    line = lines[i].split()    
    if line[4]=="000":
        s.append(i)        


### 保存
obslines = [ lines[i] for i in s]
with open(tysavepath,"w") as f:
    f.writelines(obslines)
    